package com.zzh.tree;

public class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    public TreeNode() {
    }

    public TreeNode(int val) {
        this.val = val;
    }

    public TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
    //中序遍历打印二叉树，对于bst来说，就是升序打印
    public static void printTree(TreeNode root){
        if (root==null){
            return;
        }

        printTree(root.left);
        System.out.printf("%d ",root.val);
        printTree(root.right);
//        System.out.println();
    }
    public static TreeNode initTree(){
        TreeNode root = new TreeNode(6);
        root.left = new TreeNode(4);
//        root.left.left=new TreeNode(3);
        root.right = new TreeNode(8);
        root.right.left = new TreeNode(7);
//        root.right.right = new TreeNode(7);
        return root;
    }
}
